package com.upload.controller;

import com.upload.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/upload")
public class UploadController {

    @Autowired
    private UploadService uploadService;

    /**
     * 文件上传
     * @param file 文件
     * @param path 当前路径
     * @throws IOException
     */
    @PostMapping("/file")
    public void uploadFile(@RequestPart("file") MultipartFile file,@RequestParam("path") String path) throws IOException {
        uploadService.uploadFile(file,path);
    }

}
